
import { TestUserOption } from "@/api/EmergencyDisposal/yjzhb";
const config = (_this) => {
  function checkHeight() {
    const height = `${window.innerHeight - (window.innerHeight * 0.458)}px`;
    return height;
  }
  return {
    // 列表表格
    table: {
      isSelectFlag: false,
      compRef: "yjrwlb",
      isSequenceFlag: true,
      isShowPage: true,
      resetFlag: true,
      loading: false,
      title: "应急指挥部模板列表",
      actions: [
        {
          id: "add",
          text: "新增",
          type: "primary",
          btnAttr: { size: "small" }
        }
        // {
        //   id: "expor",
        //   text: "导出",
        //   btnAttr: { size: "small" }
        // }
      ],
      tableData: [],
      columns: [
        {
          prop: "templateName",
          label: "模板名称",
          align: "center"
        },
        {
          prop: "headquartersLvName",
          label: "指挥部级别",
          align: "center"
        },
        {
          prop: "cz",
          label: "操作",
          align: "center",
          fixed: "right",
          "min-width": "120px",
          render: (h, scope) => {
            let arr = [];
            if (scope.row.operate) {
              arr = [{
                name: "编辑",
                color: "#3561fd"
              },
              {
                name: "删除",
                color: "#3561fd"
              }];
            }
            return (
              <div>
                {
                  arr.map(item => {
                    return (
                      <span style={{ color: item.color, cursor: "pointer", margin: "0 10px" }} {...{
                        on: {
                          click: () => {
                            _this.actionHandle(item.name, scope);
                          }
                        }
                      }}>
                        {item.name}
                      </span>
                    );
                  })
                }
              </div >
            );
          }
        }

      ],
      tableAttr: {
        "min-height": checkHeight(),
        height: checkHeight(),
        stripe: false,
        border: true,
        fit: true,
        "show-header": true,
        "highlight-current-row": true,
        "cell-style": {
          "font-size": "16px"
        },
        "header-cell-style": {
          "text-align": "center",
          "background-color": "#B1C8F9",
          border: "1px solid #ccc",
          color: "#333333",
          "font-size": "18px"
        }
      },
      // 分页信息
      paginationAtrrs: {
        total: 0,
        "background": true,
        layout: "prev, pager, next",
        "current-page": 1,
        "page-size": 10
      }
    },
    // 列表表格
    table1: {
      isSelectFlag: false,
      compRef: "yjrwlb",
      isSequenceFlag: false,
      isShowPage: false,
      resetFlag: true,
      loading: false,
      autoHeight: true,
      multiple: false,
      title: "",
      actions: [],
      tableData: [
        {
          post: "",
          userName: "",
          contact: "",
          unitDept: "",
          duty: "",
          dept: "",
          responsibility: ""
        }
      ],
      columns: [
        {
          prop: "post",
          label: "岗位",
          align: "center",
          tooltip: true,
          render: (h, { row }) => {
            return (
              <div class='peizhi'>
                <LsdForm
                  compData={{
                    elType: "select",
                    id: "post",
                    // name: "professionCode",
                    label: " ",
                    attrs: {
                      value: "",
                      clearable: true,
                      filterable: true,
                      disabled: false,
                      multiple: false,
                      "collapse-tags": true
                    },
                    options: _this.zhbgwList
                  }}
                  form={row}
                  {...{
                    on: {
                      change(val) {
                        _this.zhbgwList.forEach(i => {
                          if (i.value === val) {
                            row.post = i.label;
                            row.responsibility = i.dicDesc;
                          }
                        });
                      }
                    }
                  }}
                ></LsdForm>
              </div>
            );
          }
        },
        {
          prop: "userName",
          label: "姓名",
          align: "center",
          "min-width": "140px",
          tooltip: true,
          render: (h, { row }) => {
            return (
              <div class='peizhi'>
                <LsdForm
                  compData={{
                    elType: "select",
                    id: "userName",
                    name: "userId",
                    label: "姓名",
                    // dic: "dic_zrbm",
                    attrs: {
                      value: "",
                      clearable: true,
                      filterable: true,
                      disabled: false,
                      multiple: false,
                      "collapse-tags": true
                    },
                    options: _this.namelist
                  }}
                  form={row}
                  {...{
                    on: {
                      change: (val) => {
                        row.userId = val;
                        _this.namelist.map(i => {
                          if (i.value === val) {
                            row.userName = i.label;
                          }
                        });
                        const parmas = {
                          pageNum: 1,
                          pageSize: 10,
                          id: val
                        };
                        TestUserOption(parmas).then(res => {
                          row.contact = res[0].contact;
                          row.duty = res[0].duty;
                          row.unitDept = res[0].unitDept;
                          row.dept = res[0].deptName;
                        });
                      }
                    }
                  }}
                ></LsdForm>
              </div>
            );
          }
        },
        {
          prop: "contact",
          label: "联系方式",
          align: "center"
          // render: (h, { row }) => {
          //   return (
          //     <div class='peizhi'>
          //       <LsdForm
          //         compData={{
          //           elType: "input",
          //           id: "taskContent",
          //           label: "联系方式",
          //           attrs: {
          //             disabled: false,
          //             autosize: true,
          //             value: "",
          //             placeholder: "请输入",
          //             min: 0,
          //             type: "textarea"
          //           }
          //         }}
          //         form={row}
          //         {...{
          //           on: {}
          //         }}
          //       ></LsdForm>
          //     </div>
          //   );
          // }
        },
        {
          prop: "unitDept",
          label: "单位及部门",
          align: "left"
        },
        {
          prop: "duty",
          label: "职务",
          align: "center"
        },
        {
          prop: "responsibility",
          label: "职责",
          align: "center",
          "min-width": "200px"
        },
        {
          prop: "cz",
          label: "操作",
          align: "center",
          fixed: "right",
          "min-width": "80px",
          render: (h, scope) => {
            return (
              <div>
                {
                  scope.$index === _this.config.table1.tableData.length - 1 && (
                    <img
                      {...{
                        class: {},
                        style: {
                          width: "16px",
                          height: "16px",
                          "margin-right": "10px"
                        },
                        attrs: {
                          src: require("@/assets/img/listAdd.png")
                        },
                        on: {
                          click: (scope) => {
                            _this.config.table1.tableData.push(
                              {
                                post: "",
                                userName: "",
                                contact: "",
                                unitDept: "",
                                duty: "",
                                dept: "",
                                responsibility: ""
                              }
                            );
                          }
                        }
                      }}
                    />
                  )
                }
                {
                  _this.config.table1.tableData.length > 1 && (
                    <img
                      {...{
                        class: {},
                        style: {
                          width: "16px",
                          height: "16px"
                        },
                        attrs: {
                          src: require("@/assets/img/listReduc.png")
                        },
                        on: {
                          click: () => {
                            _this.config.table1.tableData.splice(scope.$index, 1);
                          }
                        }
                      }}
                    />
                  )
                }
              </div>
            );
          }
        }
      ],
      tableAttr: {
        stripe: false,
        border: true,
        fit: true,
        "show-header": true,
        "highlight-current-row": true,
        "cell-style": {
          "font-size": "16px"
        },
        "header-cell-style": {
          "text-align": "center",
          "background-color": "#B1C8F9",
          border: "1px solid #ccc",
          color: "#333333",
          "font-size": "18px"
        }
      },
      // 分页信息
      paginationAtrrs: {
        total: 0,
        "background": true,
        layout: "prev, pager, next",
        "current-page": 1,
        "page-size": 10
      }
    },
    table2: {
      isSelectFlag: false,
      compRef: "fzfz",
      isSequenceFlag: false,
      isShowPage: false,
      autoHeight: true,
      resetFlag: true,
      loading: false,
      title: "",
      actions: [],
      tableData: [
        {
          groupType: "",
          userId: "",
          contact: "",
          unitDept: "",
          duty: "",
          members: "",
          dept: "",
          responsibility: ""
        }
      ],
      columns: [
        {
          prop: "workGroup",
          label: "工作组名称",
          align: "center",
          "min-width": "180px",
          tooltip: true,
          render: (h, { row }) => {
            return (
              <div class='peizhi'>
                <LsdForm
                  compData={{
                    elType: "select",
                    id: "workGroup",
                    name: "workGroupId",
                    label: "工作组名称",
                    // dic: "dic_zrbm",
                    attrs: {
                      value: "",
                      clearable: true,
                      filterable: true,
                      disabled: false,
                      multiple: false,
                      "collapse-tags": true
                    },
                    options: _this.zhbgzfzList
                  }}
                  form={row}
                  {...{
                    on: {
                      change: (val) => {
                        row.workGroupId = val;
                        _this.zhbgzfzList.forEach(i => {
                          if (i.value === val) {
                            row.workGroup = i.label;
                            row.responsibility = i.dicDesc;
                          }
                        });
                      }
                    }
                  }}
                ></LsdForm>
              </div>
            );
          }
        },
        {
          prop: "userId",
          label: "组长",
          align: "center",
          "min-width": "140px",
          tooltip: true,
          render: (h, { row }) => {
            return (
              <div class='peizhi'>
                <LsdForm
                  compData={{
                    elType: "select",
                    id: "userId",
                    name: "userName",
                    label: "组长",
                    // dic: "dic_zrbm",
                    attrs: {
                      value: "",
                      clearable: true,
                      filterable: true,
                      disabled: false,
                      multiple: false,
                      "collapse-tags": true
                    },
                    options: _this.namelist
                  }}
                  form={row}
                  {...{
                    on: {
                      change: (val) => {
                        row.userId = val;
                        const parmas = {
                          pageNum: 1,
                          pageSize: 10,
                          id: val
                        };
                        TestUserOption(parmas).then(res => {
                          // TestUserOption(parmas).then(res => {
                          row.contact = res[0].contact;
                          row.duty = res[0].duty;
                          row.unitDept = res[0].unitDept;
                          row.dept = res[0].deptName;
                        });
                        _this.namelist.map(i => {
                          if (i.value === val) {
                            row.userName = i.label;
                          }
                        });
                      }
                    }
                  }}
                ></LsdForm>
              </div>
            );
          }
        },
        {
          prop: "contact",
          label: "联系方式",
          align: "center",
          "min-width": "120px"
        },
        {
          prop: "unitDept",
          label: "单位及部门",
          align: "left",
          "min-width": "120px"
        },
        {
          prop: "duty",
          label: "职务",
          align: "center",
          "min-width": "120px"
        },
        {
          prop: "memberIds",
          label: "成员",
          align: "center",
          "min-width": "160px",
          tooltip: true,
          render: (h, { row }) => {
            return (
              <div class='select_members'>
                <LsdForm
                  compData={{
                    elType: "select",
                    id: "memberIds",
                    name: "members",
                    label: "成员",
                    // dic: "dic_zrbm",
                    attrs: {
                      value: "",
                      clearable: true,
                      filterable: false,
                      disabled: false,
                      multiple: true,
                      "collapse-tags": false
                    },
                    options: _this.namelist
                  }}
                  form={row}
                  {...{
                    on: {
                      change: (val) => {
                        // row.memberIds = val;
                        // this.namelist.map(i => {
                        //   if (i.value === val) {
                        //     row.members = i.label;
                        //   }
                        // });
                      }
                    }
                  }}
                ></LsdForm>
              </div>
            );
          }
        },
        {
          prop: "responsibility",
          label: "职责",
          align: "left",
          "min-width": "260px"
        },
        {
          prop: "cz",
          label: "操作",
          align: "center",
          fixed: "right",
          "min-width": "80px",
          render: (h, scope) => {
            return (
              <div>
                {
                  scope.$index === _this.config.table2.tableData.length - 1 && (
                    <img
                      {...{
                        class: {},
                        style: {
                          width: "16px",
                          height: "16px",
                          "margin-right": "10px"
                        },
                        attrs: {
                          src: require("@/assets/img/listAdd.png")
                        },
                        on: {
                          click: (scope) => {
                            _this.config.table2.tableData.push({
                              groupType: "",
                              userId: "",
                              contact: "",
                              unitDept: "",
                              duty: "",
                              members: "",
                              dept: "",
                              responsibility: ""
                            });
                          }
                        }
                      }}
                    />
                  )
                }
                {
                  _this.config.table2.tableData.length > 1 && (
                    <img
                      {...{
                        class: {},
                        style: {
                          width: "16px",
                          height: "16px"
                        },
                        attrs: {
                          src: require("@/assets/img/listReduc.png")
                        },
                        on: {
                          click: () => {
                            _this.config.table2.tableData.splice(scope.$index, 1);
                          }
                        }
                      }}
                    />
                  )
                }
              </div>
            );
          }
        }
      ],
      columns1: [
        {
          prop: "workGroup",
          label: "工作组名称",
          align: "center",
          "min-width": "180px",
          render: (h, { row }) => {
            return (
              <div class='peizhi'>
                {row.workGroup}
              </div>
            );
          }
        },
        {
          prop: "userId",
          label: "组长",
          align: "center",
          "min-width": "110px",
          render: (h, { row }) => {
            return (
              <div class='peizhi'>
                {row.userName}
              </div>
            );
          }
        },
        {
          prop: "contact",
          label: "联系方式",
          align: "center",
          "min-width": "120px"
        },
        {
          prop: "unitDept",
          label: "单位及部门",
          align: "center",
          "min-width": "120px"
        },
        {
          prop: "duty",
          label: "职务",
          align: "center",
          "min-width": "110px"
        },
        {
          prop: "memberIds",
          label: "成员",
          align: "center",
          "min-width": "200px",
          render: (h, { row }) => {
            return (
              <div class='peizhi'>
                {row.members}
              </div>
            );
          }
        },
        {
          prop: "responsibility",
          label: "职责",
          align: "left",
          "min-width": "260px"
        }
      ],
      tableAttr: {
        height: "",
        stripe: false,
        border: true,
        fit: true,
        "show-header": true,
        "highlight-current-row": true,
        "cell-style": {
          "font-size": "16px"
        },
        "header-cell-style": {
          "text-align": "center",
          "background-color": "#B1C8F9",
          border: "1px solid #ccc",
          "font-size": "16px"
        }
      }
    },
    activeNames: ["1", "2", "3", "4", "5"],
    // 新增应急指挥部模板
    dialogConfig: {
      title: "应急指挥部模板新增",
      isShow: false,
      type: "",
      btnList: [
        {
          name: "保存",
          type: "primary",
          id: "save",
          size: "mini"
        },
        {
          name: "取消",
          id: "cancel",
          size: "mini"
        }
      ],
      width: "80%"
    },
    // 角色配置
    dialogConfig1: {
      title: "角色设置",
      isShow: false,
      type: "",
      btnList: [
        {
          name: "保存",
          type: "primary",
          id: "save",
          size: "mini"
        },
        {
          name: "取消",
          id: "cancel",
          size: "mini"
        }
      ],
      width: "40%"
    },
    // 折叠面板
    titleConfig: [
      {
        title: "基本信息",
        name: "1",
        slot: "slot1"
      },
      {
        title: "指挥人员",
        name: "2",
        slot: "slot2"
      },
      {
        title: "工作分组",
        name: "3",
        slot: "slot3"
      }
    ],
    formConfig: {
      formData: [
        {
          label: "指挥部模板名称",
          type: "input",
          prop: "templateName",
          class: "sjgy",
          lableWidth: "170px"
        },
        // {
        //   type: "select",
        //   label: "状态",
        //   prop: "appView",
        //   name: "appViewId",
        //   lableWidth: "170px",
        //   class: "sjgy",
        //   option: [
        //     {
        //       label: "启用",
        //       value: "1"
        //     },
        //     {
        //       label: "停用",
        //       value: "2"
        //     }
        //   ]
        // },
        {
          type: "radio",
          label: "指挥部级别",
          prop: "headquartersLv",
          name: "headquartersLvName",
          class: "sjgy",
          lableWidth: "140px",
          radio: [
            {
              label: "省级指挥部",
              value: "0",
              isDisabled: false
            },
            {
              label: "现场指挥部",
              value: "1",
              isDisabled: false
            },
            {
              label: "地市指挥部",
              value: "2",
              isDisabled: false
            },
            {
              label: "县级指挥部",
              value: "3",
              isDisabled: false
            }
          ]
        }
      ],
      rules: {
        templateName: [
          { required: true, message: "请输入指挥部级别名称", trigger: "blur" }
        ]
      }
    }
  };
};
export default { config };
